<?php
     
 // echo 'this file will ...';
     
 // var_dump($_POST);
    
-// echo "<pre>";
    
-// print_r($_POST);
    
-// echo "</pre>";
 
+echo "<pre>";
 
+print_r($_POST);
 
+echo "</pre>";
     
 // echo $_GET['stuname'];
     
 // var_dump($_REQUEST);
     
  
     
 // // 写入数据
    
-$handle = fopen("file.csv", "a");
    
-$content = $_POST['stuname'] . ',' . $_POST['stunumber'] . ',' . $_POST['stuurl'] . "\n";
    
-fwrite($handle, $content);
    
-fclose($handle);
 
+// $handle = fopen("file.csv", "a");
 
+// $content = $_POST['stuname'] . ',' . $_POST['stunumber'] . ',' . $_POST['stuurl'] . "\n";
 
+// fwrite($handle, $content);
 
+// fclose($handle);
     
  
    
-// 显示数据
    
-include 'view.php';
 
+// // 显示数据
 
+// include 'view.php';
 
+
 
+
 
+// 将接收到的数据存入到数据库
 
+
 
+$dbc = mysqli_connect ('localhost', 'root', 'root', 'stuinfo');
 
+
 
+mysqli_set_charset($dbc, 'utf8mb4');
 
+
 
+$query = "INSERT INTO `stuinfo`.`info` (`name`, `class`, `no`, `giturl`) VALUES ('" . $_POST['stuname'] . "','" . $_POST['class1'] . "','" . $_POST['stunumber'] ."','" . $_POST['stuurl']."')";
 
+
 
+// $query = "INSERT INTO site (sitetype,siteurl,siteinfo) VALUES('" . $_POST['网站类别'] ."','" . $_POST['网址'] . "','" . $_POST['简介'] ."')";
 
+
 
+$r = mysqli_query($dbc, $query);
 
+
 
+echo '<pre>';
 
+var_dump($r,$query);
 
+echo '</pre>';
     
\ No newline at end of file
studentinfo/handle2.php 0 → 100644 查看文件 @ 6fa7383
@@ -0,0 +1,24 @@
 
+<?php
 
+// var_dump($_POST);
 
+// 对接收到的数据进行处理
 
+function process() {
 
+    if (isset($_POST['stuname']) && isset($_POST['stunumber']) && isset($_POST['class']) && isset($_POST['stuurl'])) {
 
+        return true;
 
+    }
 
+}
 
+// 检验用户输入数据
 
+process();
 
+// 存储数据到数据库
 
+// 连接到数据库
 
+$dbc = mysqli_connect ('localhost', 'root', 'root', 'stuinfo');
 
+// 设定连接器的编码规则
 
+mysqli_set_charset($dbc, 'utf8mb4');
 
+// 拼接SQL语句
 
+// INSERT INTO tablename (column4, column8) VALUES (valueX, valueY)
 
+$query = "INSERT INTO info (name, class, no, giturl) VALUES ('" . $_POST['stuname'] . "','" . $_POST['class'] . "','" . $_POST['stunumber'] . "','" . $_POST['stuurl'] ."')";
 
+// 执行查询
 
+$r = mysqli_query($dbc, $query);
 
+// 释放资源
 
+mysqli_free_result ($result);
 
+mysqli_close($dbc);
 
+?>
     
\ No newline at end of file
studentinfo/index.html 查看文件 @ 6fa7383
@@ -19,6 +19,10 @@
     
     .studentinfo {
     
         margin-top: 50px;
     
     }
 
+
 
+    .mar {
 
+        margin-right: 12px;
 
+    }
     
     </style>
     
 </head>
     
  
@@ -31,7 +35,7 @@
     
                         <h3 class="panel-title">学员信息收集表单</h3>
     
                     </div>
     
                     <div class="panel-body">
    
-                        <form method="post" action="handle.php">
 
+                        <form method="post" action="handle2.php">
     
                             <div class="form-group">
     
                                 <label>姓名</label>
     
                                 <input type="text" class="form-control" name="stuname" placeholder="请输入您的姓名" autofocus required>
@@ -41,6 +45,14 @@
     
                                 <input type="text" class="form-control" name="stunumber" placeholder="请输入您的学号" required>
     
                             </div>
     
                             <div class="form-group">
 
+                                <label class="radio-inline">
 
+                                    <input type="radio" name="class" id="inlineRadio1" value="0"> 56节
 
+                                </label>
 
+                                <label class="radio-inline">
 
+                                    <input type="radio" name="class" id="inlineRadio2" value="1"> 78节
 
+                                </label>
 
+                            </div>
 
+                            <div class="form-group">
     
                                 <label>仓库地址</label>
     
                                 <input type="url" name="stuurl" class="form-control" placeholder="请输入您的仓库地址" required>
     
                             </div>